package com.controller;


import com.configs.Result;
import com.dao.StaffMapper;
import com.service.impl.StaffServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;


@RestController
@RequestMapping("/staff")
public class StaffController {

    @Autowired
    private StaffMapper staffMapper;

    private StaffServiceImpl staffServiceImpl;
    public StaffController(StaffServiceImpl staffServiceImpl){
        this.staffServiceImpl = staffServiceImpl;
    }

    @GetMapping("/by")
    public Result getUserByName(@RequestParam String username) {
        return Result.success(staffMapper.getUserByName(username).toString());
    }

    @GetMapping("/count")
    public Result getUserCount() {
        return Result.success(staffServiceImpl.getStaff());
    }

    @GetMapping("/all")
    public Result getUserAll() {
        return Result.success(staffServiceImpl.getStaffAndDepartment());
    }


}

